/**
 * @author YinHang
 */
;(function () {
	var Canvas = GameFramework.inherit("ui.g2d.Displayable")(function (canvas, width, height) {
		this.graphics = new ui.g2d.Graphics(canvas.getContext("2d"));
		this.source = canvas;
		this.setWidth(width || this.source.width || 0);
		this.setHeight(height || this.source.height || 0);
	});
	
	var Prototype = Canvas.prototype;
	
	Prototype.setWidth = function (width) {
		this.$_setWidth(width);
		this.getSource().width = this.getWidth();
	};
	
	Prototype.setHeight = function (height) {
		this.$_setHeight(height);
		this.getSource().height = this.getHeight();
	};
	
	Prototype.getGraphics = function () {
		return this.graphics;
	};

	Prototype.draw = function (graphics) {
		graphics.getContext().drawImage(this.getSource(), this.getX(), this.getY());
	};
	
	GameFramework.register(Canvas);	
})();
